{extend name="public/base"}

{block name="x-body"}
    <div class="x-body">
        <form class="layui-form">
            {if $id}
            <input type="hidden" name="id" value="{$id}">
            {/if}
          <div class="layui-form-item">
              <label for="level_name" class="layui-form-label">
                  等级名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="level_name" name="level_name" required="" lay-verify="required"
                  autocomplete="off" value="{$res.level_name}" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>设置会员等级名称
              </div>
          </div>

            <div class="layui-form-item">
                <label for="amount" class="layui-form-label">
                    消费额度
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="amount" name="amount" required="" lay-verify="required"
                           autocomplete="off" value="{$res.amount}" class="layui-input" onfocus="isNum(this)">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>设置会员等级所需要的消费额度,单位：元
                </div>
            </div>

            <div class="layui-form-item">
                <label for="discount" class="layui-form-label">
                    折扣率
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="discount" name="discount" required="" lay-verify="required"
                           autocomplete="off" value="{$res.discount}" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>折扣率单位为百分比，如输入90，表示该会员等级的用户可以以商品原价的90%购买
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label for="describe" class="layui-form-label">
                    等级描述
                </label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" id="describe" name="describe" class="layui-textarea">{$res.describe}</textarea>
                </div>
            </div>

          <div class="layui-form-item">
              <label class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  {$id ? '修改' : '增加'}
              </button>
          </div>
      </form>
    </div>
    <script>
        formData('{:url("users/level_form")}', 'add', function (){
            parent.location.reload();
            // 获得frame索引
            var index = parent.layer.getFrameIndex(window.name);
            //关闭当前frame
            parent.layer.close(index);
        }, false);
    </script>
{/block}